import { request } from '@@/exports';

/**
 * 查询会议是否存在
 */
export const meetingDetail = (server: string, meetingCode: string) => {
  return request<{
    success: boolean;
    data: {
      status: number;
      meetingCode: string;
      meetingName: string;
      meetPassword: string;
      createUser: string;
    };
  }>(`${server}/api/videoMeeting/meetingDetail`, {
    params: { meetingCode },
  });
};

/**
 * 创建会议
 */
export const createVideoMeeting = (
  server: string,
  meetingName: string,
  meetPassword: string,
) => {
  return request(`${server}/api/videoMeeting/createVideoMeeting`, {
    method: 'post',
    data: { meetingName, meetPassword },
  });
};

/**
 * 删除会议
 */
export const deleteVideoMeeting = (server: string, meetingCode: string) => {
  return request(`${server}/api/videoMeeting/deleteVideoMeeting`, {
    method: 'delete',
    data: { meetingCode },
  });
};

/**
 * 修改会议状态
 */
export const updateVideoMeetingStatus = (
  server: string,
  meetingCode: string,
) => {
  return request(`${server}/api/videoMeeting/updateVideoMeetingStatus`, {
    method: 'post',
    data: { meetingCode },
  });
};

/**
 * 获取入会人员
 */
export const getInitiationUserList = (
  server: string,
  userName: string,
  meetingCode: string,
) => {
  return request(
    `${server}/api/videoMeeting/getInitiationUserList?userName=` +
      userName +
      '&meetingCode=' +
      meetingCode,
    {
      method: 'get',
    },
  );
};
/**
 * 生成uuid
 */
export const getSelfGrowthId = (server: string) => {
  return request(`${server}/api/videoMeeting/getSelfGrowthId`, {
    method: 'get',
  });
};

/**
 * 获取未入会人员
 */
export const getNotInitiationUserList = (server: string, userName: string) => {
  return request(
    `${server}/api/videoMeeting/getNotInitiationUserList?userName=` + userName,
    {
      method: 'get',
    },
  );
};

/**
 * 获取黑名单成员
 */
export const getBlackList = (server: string, userName: string) => {
  return request(
    `${server}/api/videoMeeting/getBlackList?userName=` + userName,
    {
      method: 'get',
    },
  );
};

/**
 * 获取黑名单成员
 */
export const deleteBlackList = (server: string, ids: string) => {
  return request(`${server}/api/meetManage/deletedList?ids=` + ids, {
    method: 'get',
  });
};

/**
 * 创建会议
 */
export const createAppointMeeting = (server: string, data: any) => {
  return request(`${server}/api/videoMeeting/createAppointMeeting`, {
    method: 'post',
    data: data,
  });
};

/**
 * 获取会议时长
 */
export const getMeetingTime = (server: string) => {
  return request(`${server}/api/videoMeeting/getMeetingTime`, {
    method: 'get',
  });
};

/**
 * 我的会议
 */
export const myMeeting = (
  server: string,
  params: {
    [p: string]: any;
    filter: Record<string, (string | number)[] | null>;
    current?: number;
    pageSize?: number;
    sort: Record<string, 'descend' | 'ascend' | null>;
    keyword?: string;
  },
) => {
  return request(`${server}/api/videoMeeting/myMeeting`, {
    method: 'get',
    params: {
      ...params,
    },
  });
};

/**
 * 会议列表
 */
export const getMeetingList = (
  server: string,
  params: {
    [p: string]: any;
    filter: Record<string, (string | number)[] | null>;
    current?: number;
    pageSize?: number;
    sort: Record<string, 'descend' | 'ascend' | null>;
    keyword?: string;
  },
) => {
  return request(`${server}/api/videoMeeting/meetingList`, {
    method: 'get',
    params: {
      ...params,
    },
  });
};

/**
 * 取消会议
 */
export const cancelMeeting = (server: string, id: number) => {
  return request(`${server}/api/videoMeeting/cancelMeeting?id=` + id, {
    method: 'get',
  });
};

/**
 * 更新会议状态
 */
export const updateMeetingStatus = (server: string, meetingCode: string) => {
  return request(
    `${server}/api/videoMeeting/updateMeetingStatus?meetingCode=` + meetingCode,
    {
      method: 'get',
    },
  );
};
